﻿@model Blog.Model.Admin
<div class="wrap-container">
    <form id="admin" class="layui-form" style="width: 90%;padding-top: 20px;">
        <div class="layui-form-item">
            <label class="layui-form-label">用户名：</label>
            <div class="layui-input-block">
                <input type="hidden" name="Adminid" value="@Model.Adminid" />
                <input type="text" name="AdminName" required lay-verify="required" placeholder="请输入管理员名称" autocomplete="off" class="layui-input" value="@Model.AdminName">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密&nbsp;&nbsp;&nbsp;码：</label>
            <div class="layui-input-block">
                <input type="password" name="AdminPwd" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input" value="@Model.AdminPwd">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" onclick="cleartext()" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

</div>
@section script{
    <script>
        //Demo
        layui.use(['form'], function () {
            var form = layui.form();
            form.render();
            //监听提交
            form.on('submit(formDemo)', function (data) {
                //layer.msg(JSON.stringify(data));
                $.ajax({
                type: "post",
                    url: "/Home/AddUpdateAdmin",
                    data:$("#admin").serialize(),
                   // dataType: 'Json',
                    async:true,
                success: function (result) {
                    parent.layer.msg(result);
                }
            });
                return false;
            });
        });
        function cleartext() {
            $("input[name='AdminName']").val("");
             $("input[name='AdminPwd']").val("");
        }
    </script>
}

